package com.chris.libs.example.pages.tabs.main.base;

import android.util.Log;

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.OnLifecycleEvent;

import com.chris.libs.base.x.mvpp.mvpp.AbsStandardFragmentViewProxy;
import com.chris.libs.example.common.utils.FunItemUtil;
import com.chris.libs.example.pages.ext.base.BaseExampleActivity;
import com.chris.libs.example.pages.ext.http.HttpActivity;
import com.chris.libs.example.pages.ext.http2.Http2Activity;
import com.chris.libs.example.pages.ext.recyclerview.RecyclerViewExampleActivity;

import javax.inject.Inject;

/**
 * @author Chris chan
 * Create on： 2025/2/1 10:09
 * Use for:
 * Explain:
 */
public class BaseFrameworkViewProxy extends AbsStandardFragmentViewProxy implements BaseFrameworkContract.UIView {
    private BaseFrameworkViewModel viewModel;
    @Inject
    BaseFrameworkViewHolder vh;
    private BaseFrameworkPresenter presenter;

    @Inject
    public BaseFrameworkViewProxy() {
    }

    // 初始化
    @Override
    protected void init() {
        this.viewModel = getViewModel(BaseFrameworkViewModel.class);
        this.vh.bind(this.contentView);
        this.presenter = new BaseFrameworkPresenter(this);
        this.presenter.setViewModel(this.viewModel);
    }

    // 初始化控件
    @Override
    protected void initView() {
        FunItemUtil.addButton(this.context, this.vh.llContainer, "基本框架测试", BaseExampleActivity.class);
        FunItemUtil.addButton(this.context, this.vh.llContainer, "RecyclerView", RecyclerViewExampleActivity.class);
        FunItemUtil.addButton(this.context, this.vh.llContainer, "Retrofit2", HttpActivity.class);
        FunItemUtil.addButton(this.context, this.vh.llContainer, "Retrofit2List", Http2Activity.class);
    }

    // 设置事件
    @Override
    protected void setupEvent() {
        //update(this.viewModel.getText(), this.vh.tvInfo::setText);
    }

    // 一切就绪
    @Override
    protected void onReady() {
        this.presenter.requestAndUpdate();
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    public void onResume() {
        //showMessage("测试生命周期: onResume");
        Log.d("BASE", "onResume: 测试生命周期");
    }
}
